<template>
    <div>
        <ul class="mui-table-view">
            <li class="mui-table-view-cell mui-media" v-for="item in newslist" :key="item.tid">
                <router-link :to="'/home/newsinfo/' + item.tid">
                    <img class="mui-media-object mui-pull-left" :src="item.icon">
                    <div class="mui-media-body">
                        <h2>{{item.tname}}</h2>
                        <p class='mui-ellipsis'>
                            <span>用户ID： {{item.userId}}</span>
                            <span>用户数： {{item.userCount}}</span>
                        </p>
                    </div>
                </router-link>
            </li>
        </ul>
    </div>
</template>

<script>
    import {Toast} from 'mint-ui'
    export default {
        name: "NewsList",
        data(){
            return {
                newslist: []
            }
        },
        created(){
            this.getNewsList();
        },
        methods: {
            getNewsList(){
                var instance = Toast('加载中...');
                this.$http.jsonp('livechannel/sub/1.json').then(result => {
                    instance.close();
                    try {
                        if(result.body.sublives.length > 0){
                            this.newslist = result.body.sublives;
                        }else{
                            Toast('当前数据为空！')
                        }
                    } catch (e) {
                        Toast('数据加载失败！')
                    }
                })
            }
        }
    }
</script>

<style lang="scss" scoped>
    .mui-table-view{
        li{
            h2{font-size: 14px;}
            .mui-ellipsis{
                font-size: 12px;
                color: deepskyblue;
                display: flex;
                justify-content: space-between;
            }
        }
    }
</style>